package domain.facade;

import domain.BoardFacade;
import dao.pojo.Topics;
import dao.pojo.Replys;
import dao.TopicsDao;
import dao.ReplysDao;

import java.util.ArrayList;

class BoardService implements BoardFacade {

    private TopicsDao topicsDao;
    private ReplysDao replysDao;

    protected ReplysDao getReplysDao() {
        return replysDao;
    }

    public void setReplysDao(ReplysDao replysDao) {
        this.replysDao = replysDao;
    }

    protected TopicsDao getTopicsDao() {
        return topicsDao;
    }

    public void setTopicsDao(TopicsDao topicsDao) {
        this.topicsDao = topicsDao;
    }

    public ArrayList<Topics> getAllTopics()//取得所有主题，WebBoard首页显示 close
    {
       return topicsDao.getAllTopics();
    }

    public ArrayList<Replys> getAllReplys(Topics topic)//得到某一主题的回复 close
    {
         return replysDao.getAllReplysByTopic(topic);
    }

    public boolean addTopic(Topics topic)//这是管理员的权限，可以先不实现，添加主题功能   close
    {
        topicsDao.addTopics(topic);
        return true;
    }

    public boolean deleteTopic(Topics topic)//这是管理员的权限，可以先不实现,删除主题      close
    {
        topicsDao.deleteTopics(topic);
        return true;
    }

    public boolean updateTopic(Topics topic)//这是管理员的权限，可以先不实现，更新主题内容    close
    {
        topicsDao.saveTopics(topic);
        return true;
    }

    public boolean addReply(Replys reply)//要实现，回帖功能   close
    {
        replysDao.addReplys(reply);
        return true;
    }

    public boolean deleteReply(Replys reply)//这是管理员的权限，可以先不实现,删除某一回帖  close
    {
        replysDao.deleteReplys(reply);
        return true;
    }

    public boolean orderTopic()//按照点击率排列主题，可以先不实现   =====
    {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

	public Topics getTopic(Topics topic) {
		return topicsDao.getTopics(topic);
	}
}
